package com.infore.siteManagement.entity;

import java.io.Serializable;
import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.infore.siteManagement.entity.otherEntity.Protocol;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;


/**
 * The persistent class for the STATION database table.
 * llf
 * 站点实体类
 */
//站点树视图
@NamedEntityGraph(name="station_tree",
	attributeNodes={
		@NamedAttributeNode(value ="area",subgraph ="tree_view"),
		@NamedAttributeNode(value ="provinceId",subgraph ="tree_view"),
		@NamedAttributeNode(value ="cityId",subgraph ="tree_view"),
		@NamedAttributeNode("basinn"),
		@NamedAttributeNode("stationType"),
		@NamedAttributeNode("stationClassify"),
		@NamedAttributeNode("protocols"),
	},
	subgraphs = {
		@NamedSubgraph(name="tree_view",
		attributeNodes = {
			@NamedAttributeNode(value="areaLevel")
		}
		),
		@NamedSubgraph(name="projects_view",
		attributeNodes = {
			@NamedAttributeNode(value="projectType")
		}),
	}
)
//站点信息视图
@NamedEntityGraph(name="station_view",
attributeNodes={
	@NamedAttributeNode(value ="area",subgraph ="area_view"),
	@NamedAttributeNode(value ="cityId",subgraph ="area_view"),
	@NamedAttributeNode(value ="provinceId",subgraph ="area_view"),
	@NamedAttributeNode("basinn"),
	@NamedAttributeNode("stationType"),
	@NamedAttributeNode("stationClassify"),
	@NamedAttributeNode(value = "equipment",subgraph ="equipment_view"),
	@NamedAttributeNode(value = "projects",subgraph="projects_view"),
	@NamedAttributeNode("protocols")
},
subgraphs = {
	@NamedSubgraph(name="area_view",
	attributeNodes = {
		@NamedAttributeNode(value="areaLevel")
	}
	),
	@NamedSubgraph(name="projects_view",
	attributeNodes = {
		@NamedAttributeNode(value="projectType")
	}
	),
	@NamedSubgraph(name="equipment_view",
		attributeNodes = {
				@NamedAttributeNode("equipmentType"),
				@NamedAttributeNode(value ="projects",subgraph="projects_view"),
				@NamedAttributeNode(value ="instructions")
		}
		),
}
)
@Entity
@Table(name = "STATION")
@NamedQuery(name="Station.findAll", query="SELECT s FROM Station s")
public class Station implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="STATION_ID")
	@GeneratedValue(generator = "uuidGenerator")
	@GenericGenerator(name = "uuidGenerator", strategy = "uuid") // UUID生成策略
	private String stationId;

	/** 站点所在行政区域 **/
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST) 
	@JoinColumn(name = "AREA_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	private Area area = new Area();

	/** 站点所在流域 **/
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST) 
	@JoinColumn(name = "BASINN_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	private Basinn basinn = new Basinn();
	
	/** 自动监测站房标识(0否1是) **/
	@Column(name="AUTO_FLAG")
	private Integer autoFlag;

	/** 建造时间 **/
	@Temporal(TemporalType.TIMESTAMP)
	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name="BUILD_TIME")
	private Date buildTime;

	/** 站点控制等级(0国控1省控,2市控,3区控,4非控)**/
	@Column(name="CONTROL_LEVEL")
	private Integer controlorLevel;

	/** 是否验收 **/
	@Column(name = "ENABLED")
	private Integer enabled;
	
	//纬度
	@Column(name = "LATITUDE")
	private Double latitude;

	/** 负责人电话 **/
	@Column(name="LEADER_TEL")
	private String leaderTel;

	//经度
	@Column(name = "LONGITUDE")
	private Double longitude;

	/** 手动监测站房标识(0否1是) **/
	@Column(name="MANUEL_FLAG")
	private Integer manuelFlag;

	/** 是否视频监控 0否1是**/
	@Column(name="MONITOR_STATUS")
	private Integer monitorStatus;

	/** 运维公司负责人 **/
	@Column(name="OPER_COMPANY_LEADER")
	private String operCompanyLeader;

	/** 运维公司负责人电话 **/
	@Column(name="OPER_COMPANY_LEADER_TEL")
	private String operCompanyLeaderTel;

	/** 运维公司名称 **/
	@Column(name="OPER_COMPANY_NAME")
	private String operCompanyName;
	
	/** 运维公司id **/
	@Column(name="OPER_COMPANY_ID")
	private String operCompanyId;

	/** 是否对外公开(0否1是,有的站点只能环保局人查看,
	 * 部分站点数据公众可以看) **/
	@Column(name="PUBLIC_FLAG")
	private Integer publicFlag;

	/** 站点排序s **/
	@Column(name="SORT")
	private Integer sort;

	/** 站点位置 **/
	@Column(name="STATION_ADDRESS")
	private String stationAddress;

	/** 站点分类 **/
	@ManyToOne(cascade = CascadeType.PERSIST) 
	@JoinColumn(name = "STATION_TYPE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	private StationType stationType = new StationType();

	/** 站点负责人 **/
	@Column(name="STATION_LEADER")
	private String stationLeader;

	/** 站点名称 **/
	@Column(name="STATION_NAME")
	private String stationName;
	
	/**是否联网0否1是**/
	@Column(name = "NETWORKING")
	private Integer networking;
	
	/**站点mn**/
	@Column(name = "STATION_MN")
	private String stationMn;
	
	/**站点密码**/
	@Column(name = "STATION_PASSWORLD")
	private String stationPassworld;
	
	/**站点属性**/
	@Column(name = "STATION_PROPERTY")
	private String stationProperty;
	
	/**上下游省份**/
	@Column(name = "STATION_PROVINCES_UP_DOWN")
	private String stationProvincesUpDown;
	
	/**设备集合**/
	@JsonIgnoreProperties(value= {"station"})
	@OneToMany(mappedBy = "station",cascade = {CascadeType.MERGE,CascadeType.REMOVE})//,cascade = {CascadeType.MERGE,CascadeType.REMOVE}
	@NotFound(action = NotFoundAction.IGNORE)
	private Set<Equipment> equipment = new HashSet<Equipment>();
	
	/**因子/指标信息**/
	@JsonIgnoreProperties
	@ManyToMany(targetEntity = Project.class)//,cascade = CascadeType.MERGE
	@JoinTable(name = "PROJECT_AND_STATION", joinColumns={@JoinColumn(name="STATION_CODE", referencedColumnName="STATION_MN")}, 
			inverseJoinColumns={@JoinColumn(name="PROJECT_CODE", referencedColumnName="PROJECT_CODE")}) 
	private Set<Project> projects = new HashSet<Project>();
	
	/**根据站点找到协议id**/
	@JsonIgnoreProperties("station_Protocol")
	@ManyToMany(targetEntity = Protocol.class)//,cascade = CascadeType.MERGE
	@JoinTable(name = "STATION_AND_PROTOCOL", joinColumns = @JoinColumn(name = "STATION_ID"), 
	inverseJoinColumns = @JoinColumn(name = "PROTOCOL_ID")) 
	private Set<Protocol> protocols = new HashSet<Protocol>() ;
	
	/** 站点类型1（污染源，水站） **/
	@Column(name = "STATION_TYPE1")
	private String stationType1;
	
	/** 用户ID **/
	@Column(name = "USER_ID")
	private String userId;
	
	/** 目标水质 **/
	@Column(name = "TARGER_WATER_QUALITY")
	private String targerWaterQuality;
	
	/** 城市ID **/
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST) 
	@JoinColumn(name = "CITY_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	private Area cityId = new Area();
	
	/** 区域名称 **/
	@Column(name = "AREA_NAMES")
	private String areaName;
	
	/** 城市名称 **/
	@Column(name = "CITY")
	private String city;
	
	/** 城市名称 **/
	@Column(name = "CITY_NAME")
	private String cityName;
	
	/**八方位外景图*/
	@Column(name = "OUT_IMAGE")
	private String outImage;
	
	/**八方位外景图*/
	@Column(name = "INSIDE_IMAGE")
	private String insideImage;
	
	/**八方位外景图*/
	@Column(name = "BUILD_IMAGE")
	private String buildImage;
	
	/**验收时间*/
	@Column(name = "ENABLED_TIME")
	private String enableTime;
	
	/**当地管理单位*/
	@Column(name = "LOCAL_MANGERMNET_UNITS")
	private String localMangermnetUnits;
	
	/** 城市ID **/
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST) 
	@JoinColumn(name = "PROVINCE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	private Area provinceId = new Area();
	
	/**省名称*/
	@Column(name = "PROVINCE_NAME")
	private String provinceName;
	
	/**站点类别*/
	@ManyToOne
	@JoinColumn(name = "STATION_CLASSIFY_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	private StationClassify stationClassify = new StationClassify();
	
	/**站点所属河流**/
	@Column(name = "STATION_RIVER")
	private String stationRiver;
	
	/**断面功能**/
	@Column(name = "STATION_FUNCTION")
	private String stationFunction;
	
	/**站点简介**/
	@Column(name = "STATION_BRIEF_INFO")
	private String stationBriefInfo;
	
	/**周边历史**/
	@Column(name = "PERIPHERAL_HISTORY")
	private String peripheralHistory;
	
	/**断面功能**/
	@Column(name = "SUIFACE_WATER_TYPES")
	private String suifaceWaterTypes;
	
	/**数据发送频率S秒M分钟H小时**/
	@Column(name = "DATA_FREQUENCY")
	private String dataFrequency;
	
	/**站点钥匙保管人**/
	@Column(name="KEY_PERSON")
	private String keyPerson;
	
	/**是否是危化/特殊行业---1是0否**/
	@Column(name="IS_SPECIAL_BUSINESS")
	private String isSpecialBusiness;

	/**公里数**/
	@Column(name="KIL")
	private String kil;
	
	/**站点评级**/
	@Column(name="STATION_LEVEL")
	private String stationLevel;
	
	/**站点负责人名称**/
	@Column(name="STATION_LEADER_ID")
	private String stationLeaderId;
	
	@Column(name="OPCEN_ID")
	private String opcenId;
	
	@Column(name="OPCEN_NAME")
	private String opcenName;
	
	@Column(name="DEVICE_SERIAL")
	private String deviceSerial;
	
	public Station() {
	}

	public String getDeviceSerial() {
		return deviceSerial;
	}

	public void setDeviceSerial(String deviceSerial) {
		this.deviceSerial = deviceSerial;
	}

	public String getOpcenId() {
		return opcenId;
	}

	public void setOpcenId(String opcenId) {
		this.opcenId = opcenId;
	}

	public String getOpcenName() {
		return opcenName;
	}

	public void setOpcenName(String opcenName) {
		this.opcenName = opcenName;
	}

	public String getStationLeaderId() {
		return stationLeaderId;
	}

	public void setStationLeaderId(String stationLeaderId) {
		this.stationLeaderId = stationLeaderId;
	}

	public String getIsSpecialBusiness() {
		return isSpecialBusiness;
	}

	public void setIsSpecialBusiness(String isSpecialBusiness) {
		this.isSpecialBusiness = isSpecialBusiness;
	}

	public String getKil() {
		return kil;
	}

	public void setKil(String kil) {
		this.kil = kil;
	}

	public String getStationLevel() {
		return stationLevel;
	}

	public void setStationLevel(String stationLevel) {
		this.stationLevel = stationLevel;
	}

	public String getStationId() {
		return this.stationId;
	}

	public void setStationId(String stationId) {
		this.stationId = stationId;
	}

	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	public String getKeyPerson() {
		return keyPerson;
	}

	public void setKeyPerson(String keyPerson) {
		this.keyPerson = keyPerson;
	}

	public Integer getAutoFlag() {
		return this.autoFlag;
	}

	public void setAutoFlag(Integer autoFlag) {
		this.autoFlag = autoFlag;
	}

	public Date getBuildTime() {
		return this.buildTime;
	}

	public void setBuildTime(Date buildTime) {
		this.buildTime = buildTime;
	}

	public Integer getControlorLevel() {
		return this.controlorLevel;
	}

	public void setControlorLevel(Integer controlorLevel) {
		this.controlorLevel = controlorLevel;
	}

	public Integer getEnabled() {
		return this.enabled;
	}

	public void setEnabled(Integer enabled) {
		this.enabled = enabled;
	}

	public Double getLatitude() {
		return this.latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	public String getLeaderTel() {
		return this.leaderTel;
	}

	public void setLeaderTel(String leaderTel) {
		this.leaderTel = leaderTel;
	}

	public Double getLongitude() {
		return this.longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

	public Integer getManuelFlag() {
		return this.manuelFlag;
	}

	public void setManuelFlag(Integer manuelFlag) {
		this.manuelFlag = manuelFlag;
	}

	public Integer getMonitorStatus() {
		return this.monitorStatus;
	}

	public void setMonitorStatus(Integer monitorStatus) {
		this.monitorStatus = monitorStatus;
	}

	public String getOperCompanyLeader() {
		return this.operCompanyLeader;
	}

	public void setOperCompanyLeader(String operCompanyLeader) {
		this.operCompanyLeader = operCompanyLeader;
	}

	public String getOperCompanyLeaderTel() {
		return this.operCompanyLeaderTel;
	}

	public void setOperCompanyLeaderTel(String operCompanyLeaderTel) {
		this.operCompanyLeaderTel = operCompanyLeaderTel;
	}

	public String getOperCompanyName() {
		return this.operCompanyName;
	}

	public void setOperCompanyName(String operCompanyName) {
		this.operCompanyName = operCompanyName;
	}

	public Integer getPublicFlag() {
		return this.publicFlag;
	}

	public void setPublicFlag(Integer publicFlag) {
		this.publicFlag = publicFlag;
	}

	public Integer getSort() {
		return this.sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public String getStationAddress() {
		return this.stationAddress;
	}

	public void setStationAddress(String stationAddress) {
		this.stationAddress = stationAddress;
	}

	public StationType getStationType() {
		return stationType;
	}

	public void setStationType(StationType stationType) {
		this.stationType = stationType;
	}

	public String getStationLeader() {
		return this.stationLeader;
	}

	public void setStationLeader(String stationLeader) {
		this.stationLeader = stationLeader;
	}

	public String getStationName() {
		return this.stationName;
	}

	public void setStationName(String stationName) {
		this.stationName = stationName;
	}

	public Set<Equipment> getEquipment() {
		return equipment;
	}

	public void setEquipment(Set<Equipment> equipment) {
		this.equipment = equipment;
	}

	public Set<Project> getProjects() {
		return projects;
	}

	public void setProjects(Set<Project> projects) {
		this.projects = projects;
	}

	public Basinn getBasinn() {
		return basinn;
	}

	public void setBasinn(Basinn basinn) {
		this.basinn = basinn;
	}

	public Set<Protocol> getProtocols() {
		return protocols;
	}

	public void setProtocols(Set<Protocol> protocols) {
		this.protocols = protocols;
	}

	public Integer getNetworking() {
		return networking;
	}

	public void setNetworking(Integer networking) {
		this.networking = networking;
	}

	public String getStationMn() {
		return stationMn;
	}

	public void setStationMn(String stationMn) {
		this.stationMn = stationMn;
	}

	public String getStationPassworld() {
		return stationPassworld;
	}

	public void setStationPassworld(String stationPassworld) {
		this.stationPassworld = stationPassworld;
	}

	public String getStationProperty() {
		return stationProperty;
	}

	public void setStationProperty(String stationProperty) {
		this.stationProperty = stationProperty;
	}

	public String getStationProvincesUpDown() {
		return stationProvincesUpDown;
	}

	public void setStationProvincesUpDown(String stationProvincesUpDown) {
		this.stationProvincesUpDown = stationProvincesUpDown;
	}

	public String getStationType1() {
		return stationType1;
	}

	public void setStationType1(String stationType1) {
		this.stationType1 = stationType1;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getTargerWaterQuality() {
		return targerWaterQuality;
	}

	public void setTargerWaterQuality(String targerWaterQuality) {
		this.targerWaterQuality = targerWaterQuality;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public String getOutImage() {
		return outImage;
	}

	public void setOutImage(String outImage) {
		this.outImage = outImage;
	}

	public String getInsideImage() {
		return insideImage;
	}

	public void setInsideImage(String insideImage) {
		this.insideImage = insideImage;
	}

	public String getBuildImage() {
		return buildImage;
	}

	public void setBuildImage(String buildImage) {
		this.buildImage = buildImage;
	}

	public String getEnableTime() {
		return enableTime;
	}

	public void setEnableTime(String enableTime) {
		this.enableTime = enableTime;
	}

	public String getLocalMangermnetUnits() {
		return localMangermnetUnits;
	}

	public void setLocalMangermnetUnits(String localMangermnetUnits) {
		this.localMangermnetUnits = localMangermnetUnits;
	}

	public String getProvinceName() {
		return provinceName;
	}

	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}

	public StationClassify getStationClassify() {
		return stationClassify;
	}

	public void setStationClassify(StationClassify stationClassify) {
		this.stationClassify = stationClassify;
	}

	public String getStationRiver() {
		return stationRiver;
	}

	public void setStationRiver(String stationRiver) {
		this.stationRiver = stationRiver;
	}

	public String getStationFunction() {
		return stationFunction;
	}

	public void setStationFunction(String stationFunction) {
		this.stationFunction = stationFunction;
	}

	public String getOperCompanyId() {
		return operCompanyId;
	}

	public void setOperCompanyId(String operCompanyId) {
		this.operCompanyId = operCompanyId;
	}

	public String getStationBriefInfo() {
		return stationBriefInfo;
	}

	public void setStationBriefInfo(String stationBriefInfo) {
		this.stationBriefInfo = stationBriefInfo;
	}

	public String getPeripheralHistory() {
		return peripheralHistory;
	}

	public void setPeripheralHistory(String peripheralHistory) {
		this.peripheralHistory = peripheralHistory;
	}

	public String getSuifaceWaterTypes() {
		return suifaceWaterTypes;
	}

	public void setSuifaceWaterTypes(String suifaceWaterTypes) {
		this.suifaceWaterTypes = suifaceWaterTypes;
	}

	public Area getCityId() {
		return cityId;
	}

	public void setCityId(Area cityId) {
		this.cityId = cityId;
	}

	public Area getProvinceId() {
		return provinceId;
	}

	public void setProvinceId(Area provinceId) {
		this.provinceId = provinceId;
	}

	public String getDataFrequency() {
		return dataFrequency;
	}

	public void setDataFrequency(String dataFrequency) {
		this.dataFrequency = dataFrequency;
	}

}